package com.mitcub.panda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mitcub.panda.base.BaseQuery;
import com.mitcub.panda.base.BaseServiceImpl;
import com.mitcub.panda.entity.Category;
import com.mitcub.panda.mapper.CategoryMapper;
import com.mitcub.panda.query.DeptQuery;
import com.mitcub.panda.service.ICategoryService;
import com.mitcub.panda.utils.RespResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @项目名称: panda
 * @类名称: DeptServiceImpl
 * @类描述: 部门 服务实现类
 * @作者: tangloong
 * @创建时间: 2021/11/2 17:22
 */
@Service
public class CategoryServiceImpl extends BaseServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    /**
     * 获取数据列表
     * @param query 查询条件
     * @return
     */
    @Override
    public RespResult getList(BaseQuery query) {
        DeptQuery depQuery = (DeptQuery) query;
        // 查询条件
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        // 是否显示：1显示 2不显示
        if (depQuery.getStatus() != null && depQuery.getStatus() > 0) {
                queryWrapper.eq("status", depQuery.getStatus());
        }
        queryWrapper.eq("mark", 1);
        queryWrapper.orderByAsc("sort");

        // 查询数据
       // IPage<Category> page = new Page<>(depQuery.getPage(), depQuery.getLimit());
       // IPage<Category> data = categoryMapper.selectPage(page, queryWrapper);
       // List<Category> depList = data.getRecords();
        List<Category> depList = categoryMapper.selectList(queryWrapper);
        return RespResult.success("操作成功", depList, Long.valueOf(depList.size()));
    }

}